﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceModel;
using System.ServiceModel.Description;
using System.Text;
using System.Threading;

namespace WebService4
{
    class Program
    {
        private static ServiceHost _host;

        static void Main(string[] args)
        {
            var timer = new Timer(state => new GLKService().MarkConfirmedOrdersAsSoldInGLK(), null, 0, Properties.Settings.Default.MarkConfirmedOrdersAsSoldInGLK_Delay);

            using (_host = new ServiceHost(typeof(GLKService), new Uri(Properties.Settings.Default.ServiceBaseAddress)))
            {
                var smb = new ServiceMetadataBehavior
                {
                    HttpGetEnabled = true,
                    MetadataExporter = { PolicyVersion = PolicyVersion.Policy15 }
                };
                _host.Description.Behaviors.Add(smb);

                _host.Open();

                Console.WriteLine("The service is ready at {0}", Properties.Settings.Default.ServiceBaseAddress);
                Console.WriteLine("Press <Enter> to stop the service.");
                Console.ReadLine();

                _host.Close();
            }
        }

        private static void TestThread()
        {
            Console.WriteLine(DateTime.Now);
        }
    }
}
